package model

import (
	"example.com/m/v2/config"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"gorm.io/gorm/logger"
)

func Init(config *config.Config) (*gorm.DB, error) {
	gormConfig := gorm.Config{}
	if config.Env != "prod" {
		gormConfig.Logger = logger.Default.LogMode(logger.Info)
	}
	return gorm.Open(mysql.Open(config.MysqlDsn), &gormConfig)
}
